﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
    public static class GetCrew
    {
        #region Get Crew


        static testdbsEntities ctx = new testdbsEntities();

        public static List<Crew> GetCrews()
        {
            
            {
                IQueryable<Crew> tCrew = from cs in ctx.Crew
                                         select cs;
                return tCrew.ToList();
            }
        }

        public static List<Crew> GetCrews(Crew mCrew)
        {
            
            {
                IQueryable<Crew> tCrew = from cs in ctx.Crew
                                         where cs == mCrew
                                         select cs;
                return tCrew.ToList();
            }
        }

        public static List<Crew> GetCrews(Pilot mPilot, Flight mFlight, string mRole)
        {
            
            {
                IQueryable<Crew> tCrew = from cs in ctx.Crew
                                         where cs.fk_pilot == mPilot.id_pilot && cs.fk_flight == mFlight.id_flight && cs.role == mRole
                                         select cs;
                return tCrew.ToList();
            }
        }

        public static List<Crew> GetCrews(Pilot mPilot)
        {
            
            {
                IQueryable<Crew> tCrew = from cs in ctx.Crew
                                         where cs.fk_pilot == mPilot.id_pilot
                                         select cs;
                return tCrew.ToList();
            }
        }

        public static List<Crew> GetCrews(Flight mFlight)
        {
            
            {
                IQueryable<Crew> tCrew = from cs in ctx.Crew
                                         where cs.fk_flight == mFlight.id_flight
                                         select cs;
                return tCrew.ToList();
            }
        }

        public static List<Crew> GetCrewsRole(Pilot mPilot, Flight mFlight)
        {
            
            {
                IQueryable<Crew> tCrew = from cs in ctx.Crew
                                         where cs.fk_pilot == mPilot.id_pilot && cs.fk_flight == mFlight.id_flight
                                         select cs;
                return tCrew.ToList();
            }
        }

        #endregion 

    }
}
